import Vue from 'vue'
import App from './App'
// 引入全局uView
import uView from 'uview-ui';
import { init } from '@/sg/index'
Vue.use(uView);
Vue.config.productionTip = false;
// import home from './pages/tab/home.vue'
// Vue.component('home',home)
// import find from './pages/tab/find.vue'
// Vue.component('find',find)
// import college from './pages/tab/college.vue'
// Vue.component('college',college)
// import my from './pages/tab/my.vue'
// Vue.component('my',my)
import navbar from '@/components/navigation/navigation.vue'
Vue.component('navbar', navbar);

import uIcon from '@/uview-ui/components/u-icon/u-icon.vue';
Vue.component('uIcon', uIcon);

/*======================================================================
=                    global attributes and methods                     =
======================================================================*/
import apiUrls from '@/common/api/url.js'
import setting from '@/common/setting.js'
import {
	https,
	http,
	loginl,
	cms,
	shopnew
} from '@/common/api/index.js';
import {
	message,
	Router,
	Dayjs
} from '@/common/utils/index.js';
import {
	host,
	SYSTEM_CONFIG,
	PAGE_SIZE,
	VERSION_CODE,
	IS_DEV,
	UPLOAD_IMAGE_URL,
    IS_BSY_SHOP,
    DEFAULT_AVATARURL
} from '@/common/config.js';
const router = new Router({
	needLoginPages: [
		'/pages/center/fans/index',

	]
});
import basejs from '@/common/basejs'
Vue.prototype.$basejs = basejs
Vue.config.productionTip = false;
Vue.prototype.$urouter = router;
Vue.prototype.$api = http;
Vue.prototype.$https = https;
Vue.prototype.$loginl = loginl;
Vue.prototype.$cms = cms;
Vue.prototype.$shopnew = shopnew;
Vue.prototype.$message = message;

global.apiUrls = apiUrls;
global.setting = setting;
global.host = host;
global.IS_DEV = IS_DEV;
global.PAGE_SIZE = PAGE_SIZE;
global.VERSION_CODE = VERSION_CODE;
global.SYSTEM_CONFIG = SYSTEM_CONFIG;
global.UPLOAD_IMAGE_URL = UPLOAD_IMAGE_URL;
global.IS_BSY_SHOP = IS_BSY_SHOP;
global.DEFAULT_AVATARURL = DEFAULT_AVATARURL;
// 全局引入http接口
// import Request from '@/js_sdk/luch-request/luch-request/index.js' // 下载的插件
// const http = new Request();
// Vue.prototype.$http = http;
// end
// 统一api
/*===============================================================
=                           global user info                    =
===============================================================*/
global.token = '';
global.userInfo = null; // 用户信息



// 获取账户信息
try {
	let loginKey = global.IS_DEV?'USER_TOKEN_BSY_T':'USER_TOKEN_BSY_Z'
	const USER_TOKEN_BSY_Z = uni.getStorageSync(loginKey);
	const USER_INFO = uni.getStorageSync(global.IS_DEV?'USER_DATA_BSY_T':'USER_DATA_BSY_Z');
	global.token = USER_TOKEN_BSY_Z || '';
	if (USER_INFO) {
		global.userInfo = USER_INFO;
		console.log('USER_INFO', USER_INFO)
		setTimeout(() => {
			init(USER_INFO.userId);
		}, 0);
	}
	// global.userInfo = USER_INFO;
} catch (e) {
	console.log('tes', e);
}

// end
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
